package cn.ac.ict.fpevaluation.map;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

import cn.ac.ict.fpevaluation.bean.FusionBean;
import cn.ac.ict.fpevaluation.utils.Config;
//import edu.ict.IBSN.map.NS.Sample.entity.NSLocMap;
/**
 * 地图处理封装类
 * @author dufeng
 *
 */
public class MapHandler {
	
	static int DEFAULT_COMPASS_OFFSET = 0;
	/**
	 * 写入地图文件
	 */
	public static  void writeToMap(ArrayList<FusionBean> fusionResult){
		String mapPath = Config.getProperties("mapPath");
		File toFile = new File(mapPath);
		if(!toFile.exists()){
			try {
				toFile.createNewFile();
				toFile.setReadable(true);
				toFile.setWritable(true);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				System.out.println("地图文件创建不成功！");
				e.printStackTrace();
			}
		}
		try {
			DataOutputStream dos = new DataOutputStream(new FileOutputStream(toFile));
//			NSLocMap ns = NSLocMap.getInstance();
			//获取融合后的数据
 			for(int i = 0;i< fusionResult.size();i++){
 				FusionBean bean = fusionResult.get(i);
 				int size = bean.getxMagnetic().size();
				for(int j = 0; j< size;j++){
				//	int x = new Double(line.x.get(j)).intValue();
				//	int y = new Double(line.y.get(j)).intValue();
			  	//	ns.add(x,y, DEFAULT_COMPASS_OFFSET, line.mac.get(j));
				}
 			}
// 			dos.write(ns.toSerializingByteArray());
			dos.close(); 
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
